-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add enter handler for the textbox #407
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @VijithaEkanayake! A few comments from me.
py/examples/textbox.py
Outdated
elif q.args.enter_key_handler: | ||
q.page['example'].items = [ | ||
ui.text(f'textbox_enter_key_handler={q.args.enter_key_handler}'), | ||
ui.button(name='show_form', label='Back', primary=True), | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a better scenario would be to show every input filled (add the enter handler logic to q.args.show
if branch instead), not just enter handler as the enter submits the whole form, not just a single item and might cause confusion for some people. @lo5 wdyt.
py/examples/textbox.py
Outdated
@@ -36,6 +41,7 @@ async def serve(q: Q): | |||
ui.textbox(name='textbox_placeholder', label='With placeholder', placeholder='I need some input'), | |||
ui.textbox(name='textbox_disabled_placeholder', label='Disabled with placeholder', disabled=True, | |||
placeholder='I am disabled'), | |||
ui.textbox(name='enter_key_handler', label='Submits the textbox value on Enter key', icon='Search'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go with convention format: textbox_*** so textbox_enter or something for your case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: mturoci <[email protected]>
Co-authored-by: mturoci <[email protected]>
The implementation conditionally calls the keyup handler based on the values of the submit attribute. Fixes: #372
be42109
to
54ea7d5
Compare
Fixes: #372